import java.util.Scanner;

public class demo01 {
    //排序子序列
    public static int count=0;
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] arr=new int[n+1];
        for (int i = 0; i < n; i++) {
            arr[i]=sc.nextInt();
        }
        func(arr,n);
        System.out.println(count);
    }
    public static void func(int[] arr,int n){
        int i=0;
        while (i<n){
            if(arr[i]>arr[i+1]){
                while (arr[i]>=arr[i+1]&&i<n-1){
                    i++;
                }
                count++;
                i++;
            }else if(arr[i]==arr[i+1]){
                i++;
            }else{
                while (arr[i]<=arr[i+1]&&i<n-1){
                    i++;
                }
                count++;
                i++;
            }
        }
    }
}
